<%-- 
    Document   : ProsesDelete
    Created on : Jun 8, 2013, 3:11:48 PM
    Author     : Florencia
--%>


<%@page import="java.sql.Statement"%>
<%@page import="bean.Pembelian"%>
<%@page import="java.util.logging.Logger"%>
<%@page import="java.util.logging.Level"%>
<%@page import="java.sql.SQLException"%>
<%@page import="java.sql.Connection"%>
<%@page import="bean.OraConnection"%>
<%@page import="java.sql.ResultSet"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body bgcolor="#33FF33">
        <%


                    String namau = request.getParameter("nm");
                    out.print("<h1><center>Nomor nota yang didelete :" + namau + "</center>");

                    Connection conn7 = OraConnection.open("jdbc:oracle:thin:@localhost:1521:xe", "hr", "115314023");
                    Statement statement7 = null;
                    try {
                        statement7 = conn7.createStatement();
                        String sql7 = "delete from transaksi where nomornota= '"
                                + namau + "'";

                        statement7.executeUpdate(sql7);
                        conn7.close();
                    } catch (SQLException ex) {
                        Logger.getLogger(Pembelian.class.getName()).log(Level.SEVERE, null, ex);
                    }



                    out.print("<center>DAFTAR TRANSAKSI</center>");
                    out.print("<table border='2' align='center'>");
                    out.print("<tr><b>");
                    out.print("<td>NOMOR NOTA</td>");
                    out.print("<td>ID PEMBELI</td>");
                    out.print("<td>JENIS BARANG YANG DIBELI</td>");
                    out.print("<td>JUMLAH BARANG</td>");
                    out.print("<td>HARGA TOTAL</td>");
                    out.print("</b></tr>");



                    Connection conn = OraConnection.open("jdbc:oracle:thin:@localhost:1521:xe", "hr", "115314023");
                    java.sql.Statement statement = null;
                    try {
                        statement = conn.createStatement();
                    } catch (SQLException ex) {
                        Logger.getLogger(Pembelian.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    String sqQ = "select * from TRANSAKSI";
                    ResultSet result = null;
                    try {
                        result = statement.executeQuery(sqQ);
                    } catch (SQLException ex) {
                        Logger.getLogger(Pembelian.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    try {
                        while (result.next()) {
                            Pembelian pem = new Pembelian();
                            pem.setNomornota(result.getInt("nomornota"));
                            pem.setKtp(result.getString("ktp"));
                            pem.setJenis_barang(result.getString("jenis_barang"));
                            pem.setJumlah_barang(result.getInt("jumlah_barang"));
                            pem.setHarga_total(result.getInt("harga_total"));
                            out.println("<tr>");
                            out.println("<td><center>" + pem.getNomornota() + "</center></td>");
                            out.println("<td><center>" + pem.getKtp() + "</center></td>");
                            out.println("<td><center>" + pem.getJenis_barang() + "</center></td>");
                            out.println("<td><center>" + pem.getJumlah_barang() + "</center></td>");
                            out.println("<td><center>" + pem.getHarga_total() + "</center></td>");
                            out.println("</tr>");
                        }
                    } catch (SQLException ex) {
                        Logger.getLogger(Pembelian.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    try {
                        conn.close();
                    } catch (SQLException ex) {
                    }


        %>

    </body>
</html>